package com.itheima.demo;

import java.io.*;
import java.util.Arrays;

/**
 * @author Zhang_Han
 * @version 1.0
 * @date 2020/7/10 19:26
 */
public class Demo_006 {
    public static void main(String[] args) throws IOException {
        //创建字符输入流,读取文件中的数据;
        BufferedReader br = new BufferedReader(new FileReader("demo_IO\\123.txt"));
        //读取元素;
        String s = br.readLine();
        br.close();
        //System.out.println(s);
        //把数据根据空格进行切割;
        String[] split = s.split(" ");
        //将获取的每一个元素添加到数组当中;
        int[] arr = new int[split.length];
        //遍历切割出来的数组,取出每一个元素添加到新数组当中;
        for (int i = 0; i < split.length; i++) {
            String s1 = split[i];
            arr[i] = Integer.parseInt(s1);
        }
        //对数组进行排序;
        Arrays.sort(arr);
        //创建字符输出流;
        BufferedWriter bw = new BufferedWriter(new FileWriter("demo_IO\\123.txt"));
        //遍历数组,写入数据;
        for (int i : arr) {
            bw.write(i + " ");
        }
        bw.close();
    }
}
